Interface sjl.Predicate1
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Interface sjl.Predicate1

public interface Predicate1
extends Object
Defines the interface for predicate objects that takes one parameter. A predicate object is an object that can understand the compare(Object) message. It is a special case of function objects. A predicate's compare() always returns a boolean whereas a function object's perform() always return an Object.
Predicates are typically used for by the Algorithms for searching, ex: remove_copy. You must implement the actual function object with code like this:
    public class IsMale implements Predicate1 {
        public boolean compare(Object person) {
            return ((Employee)person).sex = "M";
        }
    }
This class will, when used with the remove_copy function insert all male colleagues into the result container.

Copyright © 1996 Finn Bock

See Also:
Predicate2

Method Index

 o compare(Object)
This method is executed for each call to the function object.

Methods

 o compare
  public abstract boolean compare(Object o)
This method is executed for each call to the function object.

All Packages  Class Hierarchy  This Package  Previous  Next  Index